using System.ComponentModel.DataAnnotations;
using SqlSugar;

namespace TaskProject.Domain.Plan
{
    /// <summary>
    /// 生产计划模型
    /// </summary>
    public class ProductionPlanModel
    {
        /// <summary>
        /// 生产计划ID（主键）
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        [Key]
        public int PlanId { get; set; }

        /// <summary>
        /// 计划主题
        /// </summary>
        [Required]
        [MaxLength(200)]
        public string PlanSubject { get; set; }

        /// <summary>
        /// 计划单号
        /// </summary>
        [Required]
        [MaxLength(50)]
        public string PlanOrderNumber { get; set; }

        /// <summary>
        /// 单据日期
        /// </summary>
        public DateTime? DocumentDate { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [MaxLength(500)]
        public string? Remarks { get; set; }

        /// <summary>
        /// 销售订单号（可选）
        /// </summary>
        [MaxLength(50)]
        public string? SalesOrderNumber { get; set; }

        /// <summary>
        /// 关联项目名称
        /// </summary>
        [MaxLength(100)]
        public string? RelatedProjectName { get; set; }

        /// <summary>
        /// 计划状态（0-草稿，1-已确认，2-执行中，3-已完成，4-已取消）
        /// </summary>
        public int PlanStatus { get; set; } = 0;

        /// <summary>
        /// 预计开始日期
        /// </summary>
        public DateTime? ExpectedStartDate { get; set; }

        /// <summary>
        /// 预计完成日期
        /// </summary>
        public DateTime? ExpectedEndDate { get; set; }

        /// <summary>
        /// 生产线
        /// </summary>
        [MaxLength(100)]
        public string? ProductionLine { get; set; }

        /// <summary>
        /// 优先级（1-低，2-中，3-高，4-紧急）
        /// </summary>
        public int Priority { get; set; } = 2;

        /// <summary>
        /// 创建人
        /// </summary>
        [MaxLength(50)]
        public string? CreateName { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreateDate { get; set; }

        /// <summary>
        /// 更新人
        /// </summary>
        [MaxLength(50)]
        public string UpdateName { get; set; } = string.Empty;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateDate { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否删除
        /// </summary>
        public bool IsDel { get; set; } = false;

        /// <summary>
        /// 生产物品列表
        /// </summary>
        public List<ProductionPlanItemModel> ProductionItems { get; set; } = new List<ProductionPlanItemModel>();

        /// <summary>
        /// 附件列表
        /// </summary>
        public List<ProductionPlanAttachmentModel> Attachments { get; set; } = new List<ProductionPlanAttachmentModel>();
    }

    /// <summary>
    /// 生产计划物品模型
    /// </summary>
    public class ProductionPlanItemModel
    {
        /// <summary>
        /// 生产计划物品ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        [Key]
        public int PlanItemId { get; set; }

        /// <summary>
        /// 生产计划ID（外键）
        /// </summary>
        public int PlanId { get; set; }

        /// <summary>
        /// 物品编号
        /// </summary>
        [Required]
        [MaxLength(50)]
        public string ItemNumber { get; set; }

        /// <summary>
        /// 物品名称
        /// </summary>
        [Required]
        [MaxLength(200)]
        public string ItemName { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        [MaxLength(100)]
        public string? SpecificationModel { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        [MaxLength(20)]
        public string? Unit { get; set; }

        /// <summary>
        /// 物品类别
        /// </summary>
        [MaxLength(50)]
        public string? ItemCategory { get; set; }

        /// <summary>
        /// 物品分类
        /// </summary>
        [MaxLength(50)]
        public string? ItemClassification { get; set; }

        /// <summary>
        /// 品牌
        /// </summary>
        [MaxLength(100)]
        public string? Brand { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        [Required]
        public int Quantity { get; set; }

        /// <summary>
        /// 计划数量
        /// </summary>
        public int PlannedQuantity { get; set; }

        /// <summary>
        /// 完成数量
        /// </summary>
        public int CompletedQuantity { get; set; } = 0;

        /// <summary>
        /// 排序序号
        /// </summary>
        public int SortOrder { get; set; }
    }

    /// <summary>
    /// 生产计划附件模型
    /// </summary>
    public class ProductionPlanAttachmentModel
    {
        /// <summary>
        /// 附件ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true)]
        [Key]
        public int AttachmentId { get; set; }

        /// <summary>
        /// 生产计划ID（外键）
        /// </summary>
        public int PlanId { get; set; }

        /// <summary>
        /// 文件名
        /// </summary>
        [Required]
        [MaxLength(200)]
        public string FileName { get; set; }

        /// <summary>
        /// 文件大小（字节）
        /// </summary>
        public long FileSize { get; set; }

        /// <summary>
        /// 文件路径
        /// </summary>
        [Required]
        [MaxLength(500)]
        public string FilePath { get; set; }

        /// <summary>
        /// 文件类型
        /// </summary>
        [MaxLength(100)]
        public string? FileType { get; set; }

        /// <summary>
        /// 上传时间
        /// </summary>
        public DateTime? UploadDate { get; set; }

        /// <summary>
        /// 上传人
        /// </summary>
        [MaxLength(50)]
        public string? UploadBy { get; set; }
    }
} 